package de.ipk_gatersleben.bit.bi.edal.rmi.sample.gui;

import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Window;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import de.ipk_gatersleben.bit.bi.edal.primary_data.security.EdalAuthenticateException;
import de.ipk_gatersleben.bit.bi.edal.publication.IpkAuthenticationProcess;
import de.ipk_gatersleben.bit.bi.edal.rmi.client.ClientDataManager;
import de.ipk_gatersleben.bit.bi.edal.rmi.client.gui.EdalFileChooser;
import de.ipk_gatersleben.bit.bi.edal.rmi.server.Authentication;
import de.ipk_gatersleben.bit.bi.edal.rmi.server.EdalServer;

public class StartGUI {

	public static void main(String[] args) throws EdalAuthenticateException {

		Authentication authentication = new Authentication(
				new IpkAuthenticationProcess().getSubject());

		final ClientDataManager dataManagerClient = new ClientDataManager(
				EdalServer.DEFAULT_REGISTRY_PORT, "bit-10", authentication);

		JFrame frame = new JFrame();

		Window window = frame.getContentPane() instanceof Window ? (Window) frame
				.getContentPane() : SwingUtilities.getWindowAncestor(frame
				.getContentPane());

		EdalFileChooser dlg = window instanceof Frame ? new EdalFileChooser(
				(Frame) window, dataManagerClient) : new EdalFileChooser(
				(Dialog) window, dataManagerClient);

		dlg.setFileSelectionMode(EdalFileChooser.FILES_AND_DIRECTORIES);

		dlg.showOpenDialog();

	}

}
